package com.xidian.zhiancloud.controller.riskcontrol.riskevaluate;


import com.xidian.zhiancloud.controller.base.BaseController;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.riskcontrol.TRiskEvaMethSetCriteList;
import com.xidian.zhiancloud.service.riskcontrol.riskevaluate.TRiskEvaMethSetCriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 风险管控-系统设置-风险评价方法设置-两个字段
 */
@RestController
@RequestMapping("/triskevamethsetcrite")
public class TRiskEvaMethSetCriteController extends BaseController {

    @Autowired
    TRiskEvaMethSetCriteService tRiskEvaMethSetCriteService;

    /**
     * 系统设置-风险评价方法设置列表
     * @param evaMethodSetId 评价方法设置ID
     * @param criteria 判定准则
     * @return 返回 ResultDTO 对象
     */
    @RequestMapping("/getTRiskEvaMethSetCriteList")
    public ResultDTO getTRiskEvaMethSetCriteList(@RequestParam("evaMethodSetId")
           String evaMethodSetId,@RequestParam("criteria") String criteria){
        Long companyId=this.getSessionUserCompanyId();
        return ResultDTO.successOf(tRiskEvaMethSetCriteService.
               getTRiskEvaMethSetCriteList(companyId,evaMethodSetId,criteria),
                GeneralResponseEnums.SUCCESS);
    }

    /**
     * 系统设置-风险评价方法设置添加
     *
     * @param evaMethodSetId 评价方法设置ID
     * @param criteria 判定准则
     *
     * @return 返回 ResultDTO 对象
     */
    @RequestMapping("/addTRiskEvaMethSetCrite")
    public ResultDTO addTRiskEvaMethSetCrite(
           @RequestParam("evaMethodSetId") String evaMethodSetId,
           @RequestParam("criteria") String criteria,
           TRiskEvaMethSetCriteList tRiskEvaMethSetCrite){
        Long companyId=this.getSessionUserCompanyId();
        tRiskEvaMethSetCrite.setCompanyId(companyId);
        tRiskEvaMethSetCrite.setEvaMethodSetId(evaMethodSetId);
        tRiskEvaMethSetCrite.setCriteria(criteria);
        tRiskEvaMethSetCriteService.addTRiskEvaMethSetCrite(tRiskEvaMethSetCrite);
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }

    /**
     * 系统设置-风险评价方法设置修改
     * @param id 风险评价方法设置表ID
     * @return 返回 ResultDTO 对象
     */
    @RequestMapping("/updateTRiskEvaMethSetCrite")
    public ResultDTO updateTRiskEvaMethSetCrite(@RequestParam("id") String id,
        TRiskEvaMethSetCriteList tRiskEvaMethSetCrite){
        tRiskEvaMethSetCriteService.updateTRiskEvaMethSetCrite
                (id,tRiskEvaMethSetCrite);
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }

    /**
     * 系统设置-风险评价方法设置删除
     * @param id 风险评价方法设置表ID
     *
     * @return 返回 ResultDTO 对象
     */
    @RequestMapping("/deleteTRiskEvaMethSetCrite")
    public ResultDTO deleteTRiskEvaMethSetCrite (@RequestParam("id") String id){
        tRiskEvaMethSetCriteService.deleteTRiskEvaMethSetCrite (id);
        return ResultDTO.successOf(GeneralResponseEnums.SUCCESS);
    }



}
